/*
 * ImgHunterView.java
 */
package imghunter;

import imghunter.ImgHunterBusca;
import java.awt.GridLayout;
import java.awt.Image;
import org.jdesktop.application.Action;
import org.jdesktop.application.ResourceMap;
import org.jdesktop.application.SingleFrameApplication;
import org.jdesktop.application.FrameView;
import org.jdesktop.application.TaskMonitor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import javax.swing.Timer;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.ChartUtilities;

/**
 * The application's main frame.
 */
public class ImgHunterView extends FrameView {

    private MyImage image;
    private SketchFrame sketchFrame;
    private ImgHunterBusca opcoesBusca;

    public ImgHunterView(SingleFrameApplication app) {
        super(app);

        initComponents();

        // status bar initialization - message timeout, idle icon and busy animation, etc
        ResourceMap resourceMap = getResourceMap();
        int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout");
        messageTimer = new Timer(messageTimeout, new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                statusMessageLabel.setText("");
            }
        });
        messageTimer.setRepeats(false);
        int busyAnimationRate = resourceMap.getInteger("StatusBar.busyAnimationRate");
        for (int i = 0; i < busyIcons.length; i++) {
            busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]");
        }
        busyIconTimer = new Timer(busyAnimationRate, new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                busyIconIndex = (busyIconIndex + 1) % busyIcons.length;
                statusAnimationLabel.setIcon(busyIcons[busyIconIndex]);
            }
        });
        idleIcon = resourceMap.getIcon("StatusBar.idleIcon");
        statusAnimationLabel.setIcon(idleIcon);
        progressBar.setVisible(false);

        // connecting action tasks to status bar via TaskMonitor
        TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext());
        taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListener() {

            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                String propertyName = evt.getPropertyName();
                if ("started".equals(propertyName)) {
                    if (!busyIconTimer.isRunning()) {
                        statusAnimationLabel.setIcon(busyIcons[0]);
                        busyIconIndex = 0;
                        busyIconTimer.start();
                    }
                    progressBar.setVisible(true);
                    progressBar.setIndeterminate(true);
                } else if ("done".equals(propertyName)) {
                    busyIconTimer.stop();
                    statusAnimationLabel.setIcon(idleIcon);
                    progressBar.setVisible(false);
                    progressBar.setValue(0);
                } else if ("message".equals(propertyName)) {
                    String text = (String) (evt.getNewValue());
                    statusMessageLabel.setText((text == null) ? "" : text);
                    messageTimer.restart();
                } else if ("progress".equals(propertyName)) {
                    int value = (Integer) (evt.getNewValue());
                    progressBar.setVisible(true);
                    progressBar.setIndeterminate(false);
                    progressBar.setValue(value);
                }
            }
        });
    }

    @Action
    public void showAboutBox() {
        if (aboutBox == null) {
            JFrame mainFrame = ImgHunterApp.getApplication().getMainFrame();
            aboutBox = new ImgHunterAboutBox(mainFrame);
            aboutBox.setLocationRelativeTo(mainFrame);
        }
        ImgHunterApp.getApplication().show(aboutBox);
    }

    public void showOpcoesBusca() {
        opcoesBusca = new ImgHunterBusca();
        opcoesBusca.setVisible(true);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        mainPanel = new javax.swing.JPanel();
        jlblImg = new javax.swing.JLabel();
        srclImgs = new java.awt.ScrollPane();
        jlblHist = new javax.swing.JLabel();
        menuBar = new javax.swing.JMenuBar();
        javax.swing.JMenu fileMenu = new javax.swing.JMenu();
        javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
        imgMenu = new javax.swing.JMenu();
        abrirImgMenu = new javax.swing.JMenu();
        loadImgMenuItem = new javax.swing.JMenuItem();
        loadSketchMenuItem = new javax.swing.JMenuItem();
        BWMenuItem = new javax.swing.JMenuItem();
        equalizarImgMenu = new javax.swing.JMenuItem();
        buscarMenuItem = new javax.swing.JMenuItem();
        jMenu1 = new javax.swing.JMenu();
        binMenuItem = new javax.swing.JMenuItem();
        mediaMenuItem = new javax.swing.JMenuItem();
        medianaMenuItem = new javax.swing.JMenuItem();
        maxMenuItem = new javax.swing.JMenuItem();
        minMenuItem = new javax.swing.JMenuItem();
        sobelMenuItem = new javax.swing.JMenuItem();
        prewittMenuItem = new javax.swing.JMenuItem();
        robertsMenuItem = new javax.swing.JMenuItem();
        HistogramaMenu = new javax.swing.JMenu();
        gerarHistMenuItem = new javax.swing.JMenuItem();
        javax.swing.JMenu helpMenu = new javax.swing.JMenu();
        javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem();
        statusPanel = new javax.swing.JPanel();
        javax.swing.JSeparator statusPanelSeparator = new javax.swing.JSeparator();
        statusMessageLabel = new javax.swing.JLabel();
        statusAnimationLabel = new javax.swing.JLabel();
        progressBar = new javax.swing.JProgressBar();
        jfcimgChooser = new javax.swing.JFileChooser();

        mainPanel.setName("mainPanel"); // NOI18N

        jlblImg.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

        jlblHist.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

        javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
        mainPanel.setLayout(mainPanelLayout);
        mainPanelLayout.setHorizontalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mainPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jlblHist, javax.swing.GroupLayout.DEFAULT_SIZE, 215, Short.MAX_VALUE)
                    .addComponent(jlblImg, javax.swing.GroupLayout.PREFERRED_SIZE, 215, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(srclImgs, javax.swing.GroupLayout.DEFAULT_SIZE, 462, Short.MAX_VALUE)
                .addContainerGap())
        );
        mainPanelLayout.setVerticalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mainPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(mainPanelLayout.createSequentialGroup()
                        .addComponent(jlblImg, javax.swing.GroupLayout.PREFERRED_SIZE, 215, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jlblHist, javax.swing.GroupLayout.PREFERRED_SIZE, 215, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(srclImgs, javax.swing.GroupLayout.DEFAULT_SIZE, 436, Short.MAX_VALUE))
                .addGap(317, 317, 317))
        );

        menuBar.setName("menuBar"); // NOI18N

        fileMenu.setText("File");
        fileMenu.setName("fileMenu"); // NOI18N

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(imghunter.ImgHunterApp.class).getContext().getActionMap(ImgHunterView.class, this);
        exitMenuItem.setAction(actionMap.get("quit")); // NOI18N
        exitMenuItem.setName("exitMenuItem"); // NOI18N
        fileMenu.add(exitMenuItem);

        menuBar.add(fileMenu);

        imgMenu.setText("Imagem");

        abrirImgMenu.setText("Abrir");

        loadImgMenuItem.setText("Imagem");
        loadImgMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                loadImgMenuItemActionPerformed(evt);
            }
        });
        abrirImgMenu.add(loadImgMenuItem);

        loadSketchMenuItem.setText("Rascunho");
        loadSketchMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                loadSketchMenuItemActionPerformed(evt);
            }
        });
        abrirImgMenu.add(loadSketchMenuItem);

        imgMenu.add(abrirImgMenu);

        BWMenuItem.setText("Tons de Cinza");
        BWMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BWMenuItemActionPerformed(evt);
            }
        });
        imgMenu.add(BWMenuItem);

        equalizarImgMenu.setText("Equalizar Imagem");
        equalizarImgMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                equalizarImgMenuActionPerformed(evt);
            }
        });
        imgMenu.add(equalizarImgMenu);

        buscarMenuItem.setText("Buscar");
        buscarMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buscarMenuItemActionPerformed(evt);
            }
        });
        imgMenu.add(buscarMenuItem);

        menuBar.add(imgMenu);

        jMenu1.setText("Filtros");

        binMenuItem.setText("Binarização");
        binMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                binMenuItemActionPerformed(evt);
            }
        });
        jMenu1.add(binMenuItem);

        mediaMenuItem.setText("Média");
        mediaMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mediaMenuItemActionPerformed(evt);
            }
        });
        jMenu1.add(mediaMenuItem);

        medianaMenuItem.setText("Mediana");
        medianaMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                medianaMenuItemActionPerformed(evt);
            }
        });
        jMenu1.add(medianaMenuItem);

        maxMenuItem.setText("Máximo");
        maxMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                maxMenuItemActionPerformed(evt);
            }
        });
        jMenu1.add(maxMenuItem);

        minMenuItem.setText("Mínimo");
        minMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                minMenuItemActionPerformed(evt);
            }
        });
        jMenu1.add(minMenuItem);

        sobelMenuItem.setText("Sobel");
        sobelMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                sobelMenuItemActionPerformed(evt);
            }
        });
        jMenu1.add(sobelMenuItem);

        prewittMenuItem.setText("Prewitt");
        prewittMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                prewittMenuItemActionPerformed(evt);
            }
        });
        jMenu1.add(prewittMenuItem);

        robertsMenuItem.setText("Roberts");
        robertsMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                robertsMenuItemActionPerformed(evt);
            }
        });
        jMenu1.add(robertsMenuItem);

        menuBar.add(jMenu1);

        HistogramaMenu.setText("Histograma");

        gerarHistMenuItem.setText("Gerar Histograma");
        gerarHistMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                gerarHistMenuItemActionPerformed(evt);
            }
        });
        HistogramaMenu.add(gerarHistMenuItem);

        menuBar.add(HistogramaMenu);

        helpMenu.setText("Help");
        helpMenu.setName("helpMenu"); // NOI18N

        aboutMenuItem.setAction(actionMap.get("showAboutBox")); // NOI18N
        aboutMenuItem.setName("aboutMenuItem"); // NOI18N
        helpMenu.add(aboutMenuItem);

        menuBar.add(helpMenu);

        statusPanel.setName("statusPanel"); // NOI18N

        statusMessageLabel.setName("statusMessageLabel"); // NOI18N

        statusAnimationLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        statusAnimationLabel.setName("statusAnimationLabel"); // NOI18N

        progressBar.setName("progressBar"); // NOI18N

        javax.swing.GroupLayout statusPanelLayout = new javax.swing.GroupLayout(statusPanel);
        statusPanel.setLayout(statusPanelLayout);
        statusPanelLayout.setHorizontalGroup(
            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(statusPanelSeparator, javax.swing.GroupLayout.DEFAULT_SIZE, 709, Short.MAX_VALUE)
            .addGroup(statusPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(statusMessageLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 525, Short.MAX_VALUE)
                .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(statusAnimationLabel)
                .addContainerGap())
        );
        statusPanelLayout.setVerticalGroup(
            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(statusPanelLayout.createSequentialGroup()
                .addComponent(statusPanelSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(statusMessageLabel)
                    .addComponent(statusAnimationLabel)
                    .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(3, 3, 3))
        );

        setComponent(mainPanel);
        setMenuBar(menuBar);
        setStatusBar(statusPanel);
    }// </editor-fold>//GEN-END:initComponents

    private void gerarHistMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_gerarHistMenuItemActionPerformed

        if (this.image.getImg() != null) {

            Histograma hist = new Histograma(image);
            BufferedImage img = this.image.getImg();

            final ChartPanel panel = new ChartPanel(hist.getChart());
            JFrame f = new JFrame("Histograma");
            f.setSize(800, 600);

            try {
                ChartUtilities.saveChartAsJPEG(new File("histograma.JPG"), hist.getChart(), 800, 600);
                img = ImageIO.read(new File("histograma.JPG"));

                ImageIcon icon = new ImageIcon(MyImage.resizeImage(img, jlblHist.getWidth(), jlblHist.getHeight()));

                jlblHist.setIcon(icon);

            } catch (IOException ex) {
                Logger.getLogger(ImgHunterView.class.getName()).log(Level.SEVERE, null, ex);
            }

            f.getContentPane().add(panel);
            f.setVisible(true);
        } else {
            JOptionPane.showConfirmDialog(null, "Selecione uma opção de imagem");
        }

    }//GEN-LAST:event_gerarHistMenuItemActionPerformed

    private void loadImgMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_loadImgMenuItemActionPerformed
        this.jfcimgChooser.setDialogType(JFileChooser.OPEN_DIALOG);
        this.jfcimgChooser.setDialogTitle("Escolha uma Imagem JPG");
        int res = this.jfcimgChooser.showOpenDialog(null);


        if (res == JFileChooser.APPROVE_OPTION) {
            try {
                //carrega a foto selecionada pelo usuario

                File f = this.jfcimgChooser.getSelectedFile();
                image = new MyImage(f.getAbsolutePath());

                //ajusta tamanho da imagem
                Image img = MyImage.resizeImage(image.getImg(), jlblImg.getWidth(),
                        jlblImg.getHeight());

                ImageIcon icon = new ImageIcon(img);
                jlblImg.setIcon(icon);

                JPanel p = new JPanel(new GridLayout(5, 2, 5, 5));
                srclImgs.add(p);

                for (int i = 0; i < 10; i++) {
                    p.add(new JLabel(icon));
                }

            } catch (IOException ex) {
                Logger.getLogger(ImgHunterView.class.getName()).log(Level.SEVERE, null, ex);
            }
        }//fim do if
    }//GEN-LAST:event_loadImgMenuItemActionPerformed

    private void BWMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BWMenuItemActionPerformed
        this.image.GerarTonsDeCinza();
        //ajusta tamanho da imagem
        Image img = MyImage.resizeImage(image.getImg(), jlblImg.getWidth(),
                jlblImg.getHeight());
        ImageIcon icon = new ImageIcon(img);
        jlblImg.setIcon(icon);
    }//GEN-LAST:event_BWMenuItemActionPerformed

    private void loadSketchMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_loadSketchMenuItemActionPerformed
        this.sketchFrame = new SketchFrame(this.jlblImg);
        sketchFrame.setVisible(true);
    }//GEN-LAST:event_loadSketchMenuItemActionPerformed

    private void equalizarImgMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_equalizarImgMenuActionPerformed
        this.image.equalizar();
    }//GEN-LAST:event_equalizarImgMenuActionPerformed

    private void buscarMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buscarMenuItemActionPerformed
        this.showOpcoesBusca();
    }//GEN-LAST:event_buscarMenuItemActionPerformed

    private void binMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_binMenuItemActionPerformed
        try {

            int limiar = Integer.parseInt(JOptionPane.showInputDialog("Digite um valor para o limiar"));
            BufferedImage img = Filtros.binarizacao(this.image.getImg(), limiar, "binarizada");

            //ajusta tamanho da imagem
            Image img2 = MyImage.resizeImage(img, jlblImg.getWidth(), jlblImg.getHeight());
            ImageIcon icon = new ImageIcon(img2);
            jlblImg.setIcon(icon);

        } catch (IOException ex) {
            Logger.getLogger(ImgHunterView.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_binMenuItemActionPerformed

    private void mediaMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mediaMenuItemActionPerformed
        try {
            int maskTam = Integer.parseInt(JOptionPane.showInputDialog("Digite um valor para o "
                    + "tamanho da máscara"));

            BufferedImage img = Filtros.filtroMedia(this.image.getImg(), maskTam, "media");
            //ajusta tamanho da imagem
            Image img2 = MyImage.resizeImage(img, jlblImg.getWidth(), jlblImg.getHeight());
            ImageIcon icon = new ImageIcon(img2);
            jlblImg.setIcon(icon);
        } catch (Exception ex) {
            Logger.getLogger(ImgHunterView.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_mediaMenuItemActionPerformed

    private void medianaMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_medianaMenuItemActionPerformed
        try {
            int maskTam = Integer.parseInt(JOptionPane.showInputDialog("Digite um valor para o "
                    + "tamanho da máscara"));

            BufferedImage img = Filtros.filtroMediana(this.image.getImg(), maskTam, "mediana");
            //ajusta tamanho da imagem
            Image img2 = MyImage.resizeImage(img, jlblImg.getWidth(), jlblImg.getHeight());
            ImageIcon icon = new ImageIcon(img2);
            jlblImg.setIcon(icon);
        } catch (Exception ex) {
            Logger.getLogger(ImgHunterView.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_medianaMenuItemActionPerformed

    private void maxMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_maxMenuItemActionPerformed
        try {
            int maskTam = Integer.parseInt(JOptionPane.showInputDialog("Digite um valor para o "
                    + "tamanho da máscara"));

            BufferedImage img = Filtros.filtroMaximo(this.image.getImg(), maskTam, "maxima");
            //ajusta tamanho da imagem
            Image img2 = MyImage.resizeImage(img, jlblImg.getWidth(), jlblImg.getHeight());
            ImageIcon icon = new ImageIcon(img2);
            jlblImg.setIcon(icon);
        } catch (Exception ex) {
            Logger.getLogger(ImgHunterView.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_maxMenuItemActionPerformed

    private void minMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_minMenuItemActionPerformed
        try {
            int maskTam = Integer.parseInt(JOptionPane.showInputDialog("Digite um valor para o "
                    + "tamanho da máscara"));

            BufferedImage img = Filtros.filtroMinimo(this.image.getImg(), maskTam, "minima");
            //ajusta tamanho da imagem
            Image img2 = MyImage.resizeImage(img, jlblImg.getWidth(), jlblImg.getHeight());
            ImageIcon icon = new ImageIcon(img2);
            jlblImg.setIcon(icon);
        } catch (Exception ex) {
            Logger.getLogger(ImgHunterView.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_minMenuItemActionPerformed

    private void sobelMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sobelMenuItemActionPerformed
        try {

            this.image.GerarTonsDeCinza();
            BufferedImage img = Filtros.bordaSobel(this.image.getImg(), "sobel");

            //ajusta tamanho da imagem
            Image img2 = MyImage.resizeImage(img, jlblImg.getWidth(), jlblImg.getHeight());
            ImageIcon icon = new ImageIcon(img2);
            jlblImg.setIcon(icon);
        } catch (Exception ex) {
            Logger.getLogger(ImgHunterView.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_sobelMenuItemActionPerformed

    private void prewittMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_prewittMenuItemActionPerformed
        try {

            this.image.GerarTonsDeCinza();
            BufferedImage img = Filtros.bordaPrewitt(this.image.getImg(), "sobel");

            //ajusta tamanho da imagem
            Image img2 = MyImage.resizeImage(img, jlblImg.getWidth(), jlblImg.getHeight());
            ImageIcon icon = new ImageIcon(img2);
            jlblImg.setIcon(icon);
        } catch (Exception ex) {
            Logger.getLogger(ImgHunterView.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_prewittMenuItemActionPerformed

    private void robertsMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_robertsMenuItemActionPerformed
        try {

            this.image.GerarTonsDeCinza();
            BufferedImage img = Filtros.bordaRobert(this.image.getImg(), "sobel");

            //ajusta tamanho da imagem
            Image img2 = MyImage.resizeImage(img, jlblImg.getWidth(), jlblImg.getHeight());
            ImageIcon icon = new ImageIcon(img2);
            jlblImg.setIcon(icon);
        } catch (Exception ex) {
            Logger.getLogger(ImgHunterView.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_robertsMenuItemActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    javax.swing.JMenuItem BWMenuItem;
    javax.swing.JMenu HistogramaMenu;
    javax.swing.JMenu abrirImgMenu;
    javax.swing.JMenuItem binMenuItem;
    javax.swing.JMenuItem buscarMenuItem;
    javax.swing.JMenuItem equalizarImgMenu;
    javax.swing.JMenuItem gerarHistMenuItem;
    javax.swing.JMenu imgMenu;
    javax.swing.JMenu jMenu1;
    javax.swing.JFileChooser jfcimgChooser;
    public javax.swing.JLabel jlblHist;
    public javax.swing.JLabel jlblImg;
    javax.swing.JMenuItem loadImgMenuItem;
    javax.swing.JMenuItem loadSketchMenuItem;
    javax.swing.JPanel mainPanel;
    javax.swing.JMenuItem maxMenuItem;
    javax.swing.JMenuItem mediaMenuItem;
    javax.swing.JMenuItem medianaMenuItem;
    javax.swing.JMenuBar menuBar;
    javax.swing.JMenuItem minMenuItem;
    javax.swing.JMenuItem prewittMenuItem;
    javax.swing.JProgressBar progressBar;
    javax.swing.JMenuItem robertsMenuItem;
    javax.swing.JMenuItem sobelMenuItem;
    java.awt.ScrollPane srclImgs;
    javax.swing.JLabel statusAnimationLabel;
    javax.swing.JLabel statusMessageLabel;
    javax.swing.JPanel statusPanel;
    // End of variables declaration//GEN-END:variables
    private final Timer messageTimer;
    private final Timer busyIconTimer;
    private final Icon idleIcon;
    private final Icon[] busyIcons = new Icon[15];
    private int busyIconIndex = 0;
    private JDialog aboutBox;
}
